home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr22 / gnplt.zip / AIRFOIL.DEM < prev    next >
Text File  |  1993-05-11  |  5KB  |  172 lines

  1. #
  2. # $Id: airfoil.dem%v 3.38.2.45 1993/01/11 04:09:41 woo Exp woo $
  3. #
  4. # This demo shows how to use bezier splines to define NACA four
  5. # series airfoils and complex variables to define Joukowski
  6. # Airfoils.  It will be expanded after overplotting in implemented
  7. # to plot Coefficient of Pressure as well.
  8. #        Alex Woo, Dec. 1992
  9. #
  10. # The definitions below follows: "Bezier presentation of airfoils",
  11. # by Wolfgang Boehm, Computer Aided Geometric Design 4 (1987) pp 17-22.
  12. #
  13. #                Gershon Elber, Nov. 1992
  14. #
  15. # m = percent camber
  16. # p = percent chord with maximum camber
  17. pause 0  "NACA four series airfoils by bezier splines"
  18. pause 0  "Will add pressure distribution later with Overplotting"
  19. mm = 0.6
  20. # NACA6xxx
  21. thick = 0.09  
  22. # nine percent  NACAxx09
  23. pp = 0.4
  24. # NACAx4xx
  25. # Combined this implies NACA6409 airfoil
  26. #
  27. # Airfoil thickness function.
  28. #
  29. set xlabel "NACA6409 -- 9% thick, 40% max camber, 6% camber"
  30. x0 = 0.0
  31. y0 = 0.0
  32. x1 = 0.0
  33. y1 = 0.18556
  34. x2 = 0.03571
  35. y2 = 0.34863
  36. x3 = 0.10714
  37. y3 = 0.48919
  38. x4 = 0.21429 
  39. y4 = 0.58214
  40. x5 = 0.35714
  41. y5 = 0.55724
  42. x6 = 0.53571
  43. y6 = 0.44992
  44. x7 = 0.75000
  45. y7 = 0.30281
  46. x8 = 1.00000
  47. y8 = 0.01050
  48. #
  49. # Directly defining the order 8 Bezier basis function for a faster evaluation.
  50. #
  51. bez_d4_i0(x) =     (1 - x)**4
  52. bez_d4_i1(x) = 4 * (1 - x)**3 * x
  53. bez_d4_i2(x) = 6 * (1 - x)**2 * x**2
  54. bez_d4_i3(x) = 4 * (1 - x)**1 * x**3
  55. bez_d4_i4(x) =                  x**4
  56.  
  57. bez_d8_i0(x) =      (1 - x)**8
  58. bez_d8_i1(x) =  8 * (1 - x)**7 * x
  59. bez_d8_i2(x) = 28 * (1 - x)**6 * x**2
  60. bez_d8_i3(x) = 56 * (1 - x)**5 * x**3
  61. bez_d8_i4(x) = 70 * (1 - x)**4 * x**4
  62. bez_d8_i5(x) = 56 * (1 - x)**3 * x**5
  63. bez_d8_i6(x) = 28 * (1 - x)**2 * x**6
  64. bez_d8_i7(x) =  8 * (1 - x)    * x**7
  65. bez_d8_i8(x) =                   x**8
  66.  
  67.  
  68. m0 = 0.0
  69. m1 = 0.1
  70. m2 = 0.1
  71. m3 = 0.1
  72. m4 = 0.0
  73. mean_y(t) = m0 * mm * bez_d4_i0(t) + \
  74.         m1 * mm * bez_d4_i1(t) + \
  75.         m2 * mm * bez_d4_i2(t) + \
  76.         m3 * mm * bez_d4_i3(t) + \
  77.         m4 * mm * bez_d4_i4(t)
  78.  
  79. p0 = 0.0
  80. p1 = pp / 2
  81. p2 = pp
  82. p3 = (pp + 1) / 2
  83. p4 = 1.0
  84. mean_x(t) = p0 * bez_d4_i0(t) + \
  85.         p1 * bez_d4_i1(t) + \
  86.         p2 * bez_d4_i2(t) + \
  87.         p3 * bez_d4_i3(t) + \
  88.         p4 * bez_d4_i4(t)
  89.  
  90. z_x(x) = x0 * bez_d8_i0(x) + x1 * bez_d8_i1(x) + x2 * bez_d8_i2(x) + \
  91.      x3 * bez_d8_i3(x) + x4 * bez_d8_i4(x) + x5 * bez_d8_i5(x) + \
  92.      x6 * bez_d8_i6(x) + x7 * bez_d8_i7(x) + x8 * bez_d8_i8(x)
  93.  
  94. z_y(x, tk) = \
  95.    y0 * tk * bez_d8_i0(x) + y1 * tk * bez_d8_i1(x) + y2 * tk * bez_d8_i2(x) + \
  96.    y3 * tk * bez_d8_i3(x) + y4 * tk * bez_d8_i4(x) + y5 * tk * bez_d8_i5(x) + \
  97.    y6 * tk * bez_d8_i6(x) + y7 * tk * bez_d8_i7(x) + y8 * tk * bez_d8_i8(x)
  98.  
  99. #
  100. # Given t value between zero and one, the airfoild curve is defined as
  101. #            c(t) = mean(t1(t)) +/- z(t2(t)) n(t1(t)),
  102. #
  103. # where n is the unit normal to the mean line. See the above paper for more.
  104. #
  105. # Unfortunately, the parametrization of c(t) is not the same for mean(t1)
  106. # and z(t2). The mean line (and its normal) can assume linear function t1 = t,
  107. #                                                     -1
  108. # but the thickness z_y is, in fact, a function of z_x  (t). Since it is
  109. # not obvious how to compute this inverse function analytically, we instead
  110. # replace t in c(t) equation above by z_x(t) to get:
  111. #            c(z_x(t)) = mean(z_x(t)) +/- z(t) n(z_x(t)),
  112. #
  113. # and compute and display this instead. Note we also ignore n(t) and assumes
  114. # n(t) is constant in the y direction,
  115. #
  116.  
  117. airfoil_y1(t, thick) = mean_y(z_x(t)) + z_y(t, thick)
  118. airfoil_y2(t, thick) = mean_y(z_x(t)) - z_y(t, thick)
  119. airfoil_y(t) = mean_y(z_x(t))
  120. airfoil_x(t) = mean_x(z_x(t))
  121. set nogrid
  122. set nozero
  123. set parametric
  124. set xrange [-0.1:1.1]
  125. set yrange [-0.1:.7]
  126. set trange [ 0.0:1.0]
  127. set title "NACA6409 Airfoil"
  128. plot airfoil_x(t), airfoil_y(t) title "mean line" w l 2, \
  129.      airfoil_x(t), airfoil_y1(t, thick) title "upper surface" w l 1, \
  130.      airfoil_x(t), airfoil_y2(t, thick) title "lower surface" w l 1
  131. pause -1 "Press Return"
  132. mm = 0.0
  133. pp = .5
  134. thick = .12
  135. set title "NACA0012 Airfoil"
  136. set xlabel "12% thick, no camber -- classical test case"
  137. plot airfoil_x(t), airfoil_y(t) title "mean line" w l 2, \
  138.      airfoil_x(t), airfoil_y1(t, thick) title "upper surface" w l 1, \
  139.      airfoil_x(t), airfoil_y2(t, thick) title "lower surface" w l 1
  140. pause -1 "Press Return"
  141. set title ""
  142. set xlab ""
  143. set key
  144. set parametric
  145. set samples 100
  146. set isosamples 10
  147. set data style lines
  148. set function style lines
  149. pause 0  "Joukowski Airfoil using Complex Variables" 
  150. set title "Joukowski Airfoil using Complex Variables" 0,0
  151. set time
  152. set yrange [-.2 : 1.8]
  153. set trange [0: 2*pi]
  154. set xrange [-.6:.6]
  155. zeta(t) = -eps + (a+eps)*exp(t*{0,1})
  156. eta(t) = zeta(t) + a*a/zeta(t)
  157. eps = 0.06
  158. a =.250
  159. set xlabel "eps = 0.06 real"
  160. plot real(eta(t)),imag(eta(t))
  161. pause -1 "Press Return"
  162. eps = 0.06*{1,-1}
  163. set xlabel "eps = 0.06 + i0.06"
  164. plot real(eta(t)),imag(eta(t))
  165. pause -1 "Press Return"
  166. set title ""
  167. set xlabel ""
  168.  
  169.  
  170.